Skip to content

Avoid rc package deep imports#1071

Open
QDyanbing wants to merge 2 commits into
react-component:masterfrom
QDyanbing:avoid-deep-imports
Open

Avoid rc package deep imports#1071
QDyanbing wants to merge 2 commits into
react-component:masterfrom
QDyanbing:avoid-deep-imports

Conversation

@QDyanbing
Copy link
Copy Markdown

@QDyanbing QDyanbing commented May 21, 2026

背景

antd 侧限制继续使用 rc 包的 lib / es 深路径导入,需要将 slider 中依赖的 rc 包内部路径统一改为包根入口。

调整内容

  • 升级 @rc-component/father-plugin,使用插件统一拦截 rc 包 lib / es 深路径导入。
  • 升级 @rc-component/util,改为从 @rc-component/util 根入口导入 KeyCodewarningraf、hooks 与测试工具。
  • 合并同来源的重复 import,保持导入更清晰。
  • 补充测试环境依赖,配合当前 React 18 测试环境。

验证

  • npm run lint
  • npm run tsc
  • npm test -- --runInBand
  • npm run compile

Summary by CodeRabbit

发布说明

  • Chores

    • 升级依赖:包括 React 升级至 v18、测试库与 TypeScript ESLint 等工具更新以获得最新功能与安全修复
    • 统一并整理模块导入方式,简化代码引用路径
    • 微调 ESLint 配置结尾格式与相关配置项,保持代码风格一致
  • Tests

    • 更新测试用例的导入方式以配合依赖调整,测试逻辑与断言保持不变

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9e219a9-9f3c-4b40-8d50-ab26b466ced1

📥 Commits

Reviewing files that changed from the base of the PR and between a9c164a and b1c50a3.

📒 Files selected for processing (1)
  • .eslintrc.js
💤 Files with no reviewable changes (1)
  • .eslintrc.js

Walkthrough

本 PR 升级了 @rc-component/util 及相关开发依赖,并将仓库中对 @rc-component/util 的深层子路径导入统一为从包入口导入,同时微调了示例、源码、测试和 ESLint 配置的导入/结尾格式。

Changes

导入路径整合与依赖升级

Layer / File(s) Summary
依赖版本和 ESLint 配置更新
package.json, .eslintrc.js
@rc-component/util 升级至 ^1.11.1,React/React DOM 升级至 ^18.0.0,更新测试与 TypeScript ESLint 相关依赖;修正 .eslintrc.js 文件末尾 module.exports 的结束符为 };
源码导入路径与类型导入合并
src/Slider.tsx, src/Handles/Handle.tsx, src/Handles/index.tsx, src/hooks/useDrag.ts, src/hooks/useRange.ts, src/index.tsx, docs/examples/components/TooltipSlider.tsx
将 KeyCode、useEvent、useLayoutEffect、warning、raf 等工具从 @rc-component/util/lib/... 或深层路径改为从 @rc-component/util 包入口导入;并合并分散的 import type 与默认导入语句。
测试文件导入路径更新
tests/Range.test.tsx, tests/Slider.test.js, tests/common.test.js, tests/marks.test.js
将测试中使用的 KeyCode/keyCode、resetWarned、spyElementPrototypes 等从深层子路径改为统一从 @rc-component/util 根模块导入。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • zombieJ

Poem

🐰 深层路径换门庭,
包入口声声清,
依赖升迁把步并,
ESLint 尾分号齐,
导入简洁又轻盈。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly summarizes the main change: avoiding deep imports from rc packages by using package root entry points instead.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Around line 59-60: Update the package.json engines.node declaration to match
the minimum Node versions required by `@typescript-eslint/eslint-plugin`,
`@typescript-eslint/parser` and eslint; change the engines.node field (in
package.json) from ">=8.x" to "^12.22.0 || ^14.17.0 || >=16.0.0" so the runtime
constraint aligns with those packages and prevents incompatible Node versions
from being allowed in CI or installs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bfe79f42-be18-4fbe-8761-1ef680884fb8

📥 Commits

Reviewing files that changed from the base of the PR and between 0477cdb and a9c164a.

📒 Files selected for processing (13)
  • .eslintrc.js
  • docs/examples/components/TooltipSlider.tsx
  • package.json
  • src/Handles/Handle.tsx
  • src/Handles/index.tsx
  • src/Slider.tsx
  • src/hooks/useDrag.ts
  • src/hooks/useRange.ts
  • src/index.tsx
  • tests/Range.test.tsx
  • tests/Slider.test.js
  • tests/common.test.js
  • tests/marks.test.js

Comment thread package.json
Comment on lines +59 to +60
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

python - <<'PY'
import json
with open('package.json','r',encoding='utf-8') as f:
    pkg=json.load(f)
print("package.json engines.node =", pkg.get("engines",{}).get("node"))
for name in ["`@typescript-eslint/eslint-plugin`","`@typescript-eslint/parser`","eslint"]:
    print(name, "=>", pkg.get("devDependencies",{}).get(name) or pkg.get("dependencies",{}).get(name))
PY

echo "---- published engines metadata ----"
npm view `@typescript-eslint/eslint-plugin`@5.62.0 engines --json
npm view `@typescript-eslint/parser`@5.62.0 engines --json
npm view eslint@8.54.0 engines --json

Repository: react-component/slider

Length of output: 383


同步提升 Node 引擎声明以匹配 typescript-eslint/eslint 的最低要求

engines.node 仍为 >=8.x,但 @typescript-eslint/eslint-plugin@5.62.0@typescript-eslint/parser@5.62.0(以及 eslint@8.54.0)的发布 engines.node 均要求 ^12.22.0 || ^14.17.0 || >=16.0.0,会导致不兼容 Node 版本被错误放行并在 lint/tsc 阶段失败。建议在本 PR 同步更新下限。

建议修改
  "engines": {
-    "node": ">=8.x"
+    "node": ">=12.22.0"
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` around lines 59 - 60, Update the package.json engines.node
declaration to match the minimum Node versions required by
`@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser` and eslint; change
the engines.node field (in package.json) from ">=8.x" to "^12.22.0 || ^14.17.0
|| >=16.0.0" so the runtime constraint aligns with those packages and prevents
incompatible Node versions from being allowed in CI or installs.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates several dependencies, including a major version bump for React to v18, and refactors imports across the codebase to avoid deep imports from internal packages like @rc-component/util. Feedback was provided regarding the ESLint configuration change that disables the switch-exhaustiveness-check rule, noting that it reduces type safety and appears unrelated to the primary goal of the PR.

Comment thread .eslintrc.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant